package cn.zucc.edu.handyzucc.controller;

import cn.zucc.edu.handyzucc.entity.Article;
import cn.zucc.edu.handyzucc.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @RequestMapping(value = "getArticles", method = RequestMethod.GET)
    private Map<String, Object> getArticles() {
        Map<String, Object> modelMap = new HashMap<>();
        List<Article> articles = articleService.getArticles();
        System.out.println(articles.get(0).getArticle_time());
        modelMap.put("code", "0");
        modelMap.put("info", "查询成功");
        modelMap.put("data", articles);
        return modelMap;
    };
}
